// 配置请求
const request = (config) => {
	// let baseUrl = 'http://101.37.164.208:8801'; // 测试环境的域名
	let baseUrl = 'https://brita2024.com/basic-api'; // 测试环境的域名
	//const env = `${__wxConfig.envVersion}`;
	// if (env === 'release') {
	// 	baseUrl = 'http://101.37.164.208:8801'; // 上线之后的域名
	// }
	let data = config.data || config.params || {};
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + config.url,
			method: config.method,
			header: {
				'Authorization': uni.getStorageSync('userToken')
			},
			data: data,
			success(res) {
				if(res.data.code != '2000' && config.msg){
					uni.showToast({
						title: res.data.msg+'666',
						icon: 'none'
					})
					return;
				}
				if(res.data.code == 401){
					uni.removeStorageSync('userToken');
				}
				resolve(res.data)
			},
			fail(err) {
				reject(err)
			}
		})
	})
}
export default request